package com.mmloo.manage.authc;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mmloo.common.model.BaseModel;
import com.mmloo.manage.model.AdminUser;
import org.apache.shiro.crypto.hash.Sha512Hash;

import java.io.UnsupportedEncodingException;


public class PasswordHelper
{
	public static final String ps = "ps";
	
	public static AdminUser generatePassword(AdminUser user){
		String passwordHash = new Sha512Hash(user.getPassword(), user.getName() + ps, 99).toString();
		user.setPassword(passwordHash);
		return user;
	}
	
	public static void main(String[] args) throws UnsupportedEncodingException {
		String passwordHash = new Sha512Hash("111", "wjs" + ps, 99).toString();
		System.out.println(passwordHash);

		System.out.println("-----》"+BaseModel.class.getSimpleName());
		/*

		System.out.println("Default Charset=" + Charset.defaultCharset());
		System.out.println("file.encoding=" + System.getProperty("file.encoding"));
		System.out.println("Default Charset=" + Charset.defaultCharset());*/
		String s = "{\"errcode\":40029,\"errmsg\":\"invalid code\"}";
		JSONObject jsonObject = JSON.parseObject(s);
		String r = (String) jsonObject.get("errmsg");
		System.out.println(r);

		String s2 = new String("ռ��".getBytes("GBK"),"GBK");
		System.out.println("s2 ռ��" + s2);

	}

}
